#include "LCD_TN_FONT.h"



/*

//定时器中断调用  dis_val  显示的值   全局变量   
void lcd_tn_display(void)
{
	switch(guc_DisFreshStep)
	{
			case 0: LCDCON &=~ 0x10;
							guc_DisFreshStep = 1;
							refresh_display(COM1,dis_val);
							break;
			case 1: guc_DisFreshStep = 2;
							refresh_display(COM2,dis_val);
							break;
			case 2: guc_DisFreshStep = 3;
							refresh_display(COM3,dis_val);
							break;
			case 3: guc_DisFreshStep = 4;
							refresh_display(COM4,dis_val);
							break;
			case 4: LCDCON |= 0x10;
							guc_DisFreshStep = 5;
							refresh_display(COM1,dis_val);
							break;
			case 5: guc_DisFreshStep = 6;
							refresh_display(COM2,dis_val);
							break;        
			case 6: guc_DisFreshStep = 7;
							refresh_display(COM3,dis_val);
							break;             
			case 7: guc_DisFreshStep = 0;
							refresh_display(COM4,dis_val);
							break; 
			default:guc_DisFreshStep = 0;
							break; 
	}	
}


*/




void refresh_display(uint8_t comx,uint8_t dis_num)
{
	refresh_comx(comx);
	
	switch(dis_num)
	{
		case 0:
			refresh_seg0(comx);
		break;
		
		case 1:
			refresh_seg1(comx);
		break;
		
		case 2:
			refresh_seg2(comx);
		break;
		
		case 3:
			refresh_seg3(comx);
		break;
		
		case 4:
			refresh_seg4(comx);
		break;
		
		case 5:
			refresh_seg5(comx);
		break;
		
		case 6:
			refresh_seg6(comx);
		break;
		
		case 7:
			refresh_seg7(comx);
		break;
		
		case 8:
			refresh_seg8(comx);
		break;
		
		case 9:
			refresh_seg9(comx);
		break;
		
		case 0x0a:
			refresh_sega(comx);
		break;
		
		case 0x0b:
			refresh_segb(comx);
		break;
		
		case 0x0c:
			refresh_segc(comx);
		break;
		
		case 0x0d:
			refresh_segd(comx);
		break;
		
		case 0x0e:
			refresh_sege(comx);
		break;
		
		case 0x0f:
			refresh_segf(comx);
		break;
		
		
		default :
			refresh_seg_all_clear();
		break;
		
	}
}

void refresh_seg_all_clear(void)
{
	P3_0 = 0;
	P3_1 = 0;
	P3_2 = 0;

	P1_0 = 0;
	P1_1 = 0;
	P1_2 = 0;
	P1_3 = 0;
	P1_4 = 0;
}



void refresh_comx(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
			refresh_com1();
		break;
		
		case COM2:
			refresh_com2();
		break;
		
		case COM3:
			refresh_com3();
		break;
		
		case COM4:
			refresh_com4();
		break;
		
		default :
			refresh_com1();
		break;
		
	}
}





void refresh_com1(void)
{
	P0_4 = 1;
	P0_5 = 0;
	P0_6 = 0;
	P0_7 = 0;
}
void refresh_com2(void)
{
	P0_4 = 0;
	P0_5 = 1;
	P0_6 = 0;
	P0_7 = 0;
}
void refresh_com3(void)
{
	P0_4 = 0;
	P0_5 = 0;
	P0_6 = 1;
	P0_7 = 0;
}
void refresh_com4(void)
{
	P0_4 = 0;
	P0_5 = 0;
	P0_6 = 0;
	P0_7 = 1;
}

void refresh_seg0(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
		
	}

}
void refresh_seg1(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_seg2(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_seg3(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_seg4(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_seg5(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_seg6(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}


void refresh_seg7(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}


void refresh_seg8(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}


void refresh_seg9(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_sega(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_segb(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_segc(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_segd(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM2:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_sege(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 1;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}

void refresh_segf(uint8_t comx)
{
	switch(comx)
	{
		case COM1:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM2:
				P3_0 = 1;
				P3_1 = 1;
		break;
		
		case COM3:
				P3_0 = 1;
				P3_1 = 0;
		break;
		
		case COM4:
				P3_0 = 0;
				P3_1 = 0;
		break;
		
		default :
			P3_0 = 0;
			P3_1 = 0;
		break;
	}

}


